Skip to content

[triton-ext] Fix garbage string in reported errors#9687

Merged
lezcano merged 1 commit into
triton-lang:mainfrom
abrown:fix-twine-use
Mar 10, 2026
Merged

[triton-ext] Fix garbage string in reported errors#9687
lezcano merged 1 commit into
triton-lang:mainfrom
abrown:fix-twine-use

Conversation

@abrown
Copy link
Copy Markdown
Contributor

@abrown abrown commented Mar 10, 2026

When loading an extension library, it is possible that the library is reported invalid by llvm::sys::DynamicLibrary::getPermanentLibrary; e.g., if the loaded library has undefined symbols. When trying to add dialects in triton-ext, I observed some garbage output when loading extensions:

$ LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib
 TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
LLVM ERROR: {X��J�iij(��h��[ijh��x����������

Aborted                    (core dumped) LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt

I tracked this down to incorrect usage of llvm::Twine and llvm::createStringError. Suspecting that the string messages were not being moved into the error and thus being corrupted by stack movement, I switched all uses of llvm::createStringError to use the pattern I see in LLVM. This fixes the garbage error string problem so now I see the proper error:

LLVM ERROR: Failed to load plugin library: triton/build/install/lib64/libtriton.so: undefined symbol: _Py_NoneStruct

When loading an extension library, it is possible that the library is
reported invalid by `llvm::sys::DynamicLibrary::getPermanentLibrary`;
e.g., if the loaded library has undefined symbols. When trying to add
dialects in [triton-ext], I observed some garbage output when loading
extensions:

```console
$ LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib
 TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
LLVM ERROR: {X��J�iij(��h��[ijh��x����������

Aborted                    (core dumped) LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
```

I tracked this down to incorrect usage of `llvm::Twine` and
`llvm::createStringError`. Suspecting that the string messages were not
being moved into the error and thus being corrupted by stack movement, I
switched all uses of `llvm::createStringError` to use the pattern I see
in LLVM. This fixes the garbage error string problem so now I see the
proper error:

```
LLVM ERROR: Failed to load plugin library: triton/build/install/lib64/libtriton.so: undefined symbol: _Py_NoneStruct
```

[triton-ext]: https://github.com/triton-lang/triton-ext
@abrown abrown requested a review from lezcano as a code owner March 10, 2026 23:06
Copy link
Copy Markdown
Contributor

@sjw36 sjw36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find! Thanks

@lezcano lezcano enabled auto-merge (squash) March 10, 2026 23:16
@lezcano lezcano merged commit 47f9e51 into triton-lang:main Mar 10, 2026
9 checks passed
@abrown abrown deleted the fix-twine-use branch March 11, 2026 00:32
raymondtay pushed a commit to raymondtay/triton that referenced this pull request Mar 22, 2026
When loading an extension library, it is possible that the library is
reported invalid by `llvm::sys::DynamicLibrary::getPermanentLibrary`;
e.g., if the loaded library has undefined symbols. When trying to add
dialects in [triton-ext], I observed some garbage output when loading
extensions:

```console
$ LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib
 TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
LLVM ERROR: {X��J�iij(��h��[ijh��x����������

Aborted                    (core dumped) LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
```

I tracked this down to incorrect usage of `llvm::Twine` and
`llvm::createStringError`. Suspecting that the string messages were not
being moved into the error and thus being corrupted by stack movement, I
switched all uses of `llvm::createStringError` to use the pattern I see
in LLVM. This fixes the garbage error string problem so now I see the
proper error:

```
LLVM ERROR: Failed to load plugin library: triton/build/install/lib64/libtriton.so: undefined symbol: _Py_NoneStruct
```

[triton-ext]: https://github.com/triton-lang/triton-ext
jvican pushed a commit to jvican/triton that referenced this pull request Mar 27, 2026
When loading an extension library, it is possible that the library is
reported invalid by `llvm::sys::DynamicLibrary::getPermanentLibrary`;
e.g., if the loaded library has undefined symbols. When trying to add
dialects in [triton-ext], I observed some garbage output when loading
extensions:

```console
$ LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib
 TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
LLVM ERROR: {X��J�iij(��h��[ijh��x����������

Aborted                    (core dumped) LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
```

I tracked this down to incorrect usage of `llvm::Twine` and
`llvm::createStringError`. Suspecting that the string messages were not
being moved into the error and thus being corrupted by stack movement, I
switched all uses of `llvm::createStringError` to use the pattern I see
in LLVM. This fixes the garbage error string problem so now I see the
proper error:

```
LLVM ERROR: Failed to load plugin library: triton/build/install/lib64/libtriton.so: undefined symbol: _Py_NoneStruct
```

[triton-ext]: https://github.com/triton-lang/triton-ext
plotfi pushed a commit to plotfi/triton that referenced this pull request Apr 8, 2026
When loading an extension library, it is possible that the library is
reported invalid by `llvm::sys::DynamicLibrary::getPermanentLibrary`;
e.g., if the loaded library has undefined symbols. When trying to add
dialects in [triton-ext], I observed some garbage output when loading
extensions:

```console
$ LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib
 TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
LLVM ERROR: {X��J�iij(��h��[ijh��x����������

Aborted                    (core dumped) LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
```

I tracked this down to incorrect usage of `llvm::Twine` and
`llvm::createStringError`. Suspecting that the string messages were not
being moved into the error and thus being corrupted by stack movement, I
switched all uses of `llvm::createStringError` to use the pattern I see
in LLVM. This fixes the garbage error string problem so now I see the
proper error:

```
LLVM ERROR: Failed to load plugin library: triton/build/install/lib64/libtriton.so: undefined symbol: _Py_NoneStruct
```

[triton-ext]: https://github.com/triton-lang/triton-ext

(cherry picked from commit 47f9e51)
plotfi pushed a commit to plotfi/triton that referenced this pull request Apr 8, 2026
When loading an extension library, it is possible that the library is
reported invalid by `llvm::sys::DynamicLibrary::getPermanentLibrary`;
e.g., if the loaded library has undefined symbols. When trying to add
dialects in [triton-ext], I observed some garbage output when loading
extensions:

```console
$ LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib
 TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
LLVM ERROR: {X��J�iij(��h��[ijh��x����������

Aborted                    (core dumped) LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
```

I tracked this down to incorrect usage of `llvm::Twine` and
`llvm::createStringError`. Suspecting that the string messages were not
being moved into the error and thus being corrupted by stack movement, I
switched all uses of `llvm::createStringError` to use the pattern I see
in LLVM. This fixes the garbage error string problem so now I see the
proper error:

```
LLVM ERROR: Failed to load plugin library: triton/build/install/lib64/libtriton.so: undefined symbol: _Py_NoneStruct
```

[triton-ext]: https://github.com/triton-lang/triton-ext

(cherry picked from commit 47f9e51)
(cherry picked from commit fa5aea3)
@plotfi plotfi mentioned this pull request Apr 8, 2026
atalman pushed a commit that referenced this pull request Apr 10, 2026
[triton-ext] Update plugin extension changes for release 3.7.x

cherry-picking the following plugin extension changes since January:

- **[triton-ext] Fix garbage string in reported errors (#9687)**
- **[triton-ext] add string arguments to addPass API (#9691)**
- **[triton-ext][FrontEnd] Custom DSL Plugin Ops (#9626)**
- **[triton-ext] Drop LLVM_BUILD_SHARED_LIBS, enable libtriton
visibility through TRITON_EXT_ENABLED (#9783)**
- **[triton-ext] Pass a single `PluginInfo *` pointer (#9748)**
- **[triton-ext] plugin extension's version check (#9937)**

---------

Co-authored-by: Andrew Brown <andrew@kernelize.ai>
Co-authored-by: Corbin Robeck <robeck@meta.com>
plognjen pushed a commit to plognjen/triton that referenced this pull request Apr 14, 2026
When loading an extension library, it is possible that the library is
reported invalid by `llvm::sys::DynamicLibrary::getPermanentLibrary`;
e.g., if the loaded library has undefined symbols. When trying to add
dialects in [triton-ext], I observed some garbage output when loading
extensions:

```console
$ LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib
 TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
LLVM ERROR: {X��J�iij(��h��[ijh��x����������

Aborted                    (core dumped) LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
```

I tracked this down to incorrect usage of `llvm::Twine` and
`llvm::createStringError`. Suspecting that the string messages were not
being moved into the error and thus being corrupted by stack movement, I
switched all uses of `llvm::createStringError` to use the pattern I see
in LLVM. This fixes the garbage error string problem so now I see the
proper error:

```
LLVM ERROR: Failed to load plugin library: triton/build/install/lib64/libtriton.so: undefined symbol: _Py_NoneStruct
```

[triton-ext]: https://github.com/triton-lang/triton-ext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants